/**
 * @param {number[]} nums
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var moveZeroes = function(nums: number[]) {
    var i = 0, j = 1;
    while(j < nums.length) {
        if(nums[i] === 0 && nums[j] !== 0) {
            var temp = nums[j];
            nums[j] = nums[i];
            nums[i] = temp;
        }
        if(!(nums[i] === 0 && nums[j] === 0)) {
            i++;
        }
        j++;
    }
};

var nums = [0, 1, 0, 3, 12];
moveZeroes(nums);
var expected = '1,3,12,0,0';
console.assert(nums.join(',') === expected);

nums = [2, 1];
moveZeroes(nums);
var expected = '2,1';
console.assert(nums.join(',') === expected);

nums = [1, 0, 1];
moveZeroes(nums);
var expected = '1,1,0';
console.assert(nums.join(',') === expected);

